//
//  CCYFriendTrendsViewController.m
//  模拟-百思不得姐
//
//  Created by 程春玉 on 16/8/1.
//  Copyright © 2016年 chunyu. All rights reserved.
//

#import "CCYFriendTrendsViewController.h"
#import "CCYRecommendViewController.h"
#import "LoginViewController.h"
#import "EMClient.h"

@interface CCYFriendTrendsViewController ()
@property (nonatomic, strong) UITableView *tab;
@end

@implementation CCYFriendTrendsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"我的关注";
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:@"friendsRecommentIcon" selectImage:@"friendsRecommentIcon-click" target:self action:@selector(friendClick)];
    self.view.backgroundColor = XMGVColor;
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(Action:) name:@"login" object:nil];
    // 注册注销通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(Action:) name:@"loginOut" object:nil];
    // Do any additional setup after loading the view.
}

- (void)Action:(NSNotification *)ation
{
    if ([ation.name isEqualToString:@"login"]) {
        self.tab = [[UITableView alloc] initWithFrame:self.view.bounds];
        [self.view addSubview:_tab];
    } else {
        [self.tab removeFromSuperview];
        self.tab = nil;
    }
}

- (void)viewDidAppear:(BOOL)animated
{
    if ([[EMClient sharedClient] currentUsername] != nil && self.tab == nil) {
        self.tab = [[UITableView alloc] initWithFrame:self.view.bounds];
        [self.view addSubview:_tab];
    }
}



- (void)friendClick
{
    CCYRecommendViewController *vc = [[CCYRecommendViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}

- (IBAction)LongBtn:(id)sender {
    LoginViewController *logVC=[[LoginViewController alloc]init];
    [self presentViewController:logVC animated:YES completion:nil];
}




 

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
